function ImageQuality = deployImgsByIterModels2(Set, ImgPairs, ModelPath, solver_mode)
global DeployImgs_LogFile

ResultPath = fileparts(ModelPath);

%%
[ModelLink, scale] = srdata.getModelLink(ModelPath);
if isempty(ModelLink)
    data_startpoint = 'Bicubic';
else
    [~, model_name] = fileparts(ModelLink{end, 2});
    data_startpoint = num2str(cell2mat(textscan(model_name, 'VDSR_y_iter_%d')));
end

st = importdata(fullfile(ResultPath, 'st.mat'));
if ~isfield(st.solv, 'weights')
    param_startpoint = 'MSRA';
else
    [~, model_name] = fileparts(st.solv.weights);
    param_startpoint = num2str(cell2mat(textscan(model_name, 'VDSR_y_iter_%d')));
end

MatPath = fileparts(ResultPath);
MatFile0 = fullfile(MatPath, sprintf('ImageQuality-%s.mat', Set));
MatFile  = fullfile(MatPath, sprintf('ImageQuality-%s-scale%d-%s-%s.mat', Set, scale, data_startpoint, param_startpoint));

% DeployImgs_LogFile = fullfile(ResultPath, 'DeployImgs_LogFile.log');
DeployImgs_LogFile = fullfile(MatPath, sprintf('DeployLogFile-%s-scale%d-%s-%s.log', Set, scale, data_startpoint, param_startpoint));


if exist(MatFile0, 'file') == 2 && exist(MatFile, 'file') ~= 2
    movefile(MatFile0, MatFile, 'f');
end

%%
ImageQuality = cell(1, 3);
if exist(MatFile, 'file') ~= 2
    [~, ImageQuality{:}] = srdata.deployImgsByIterModels(ImgPairs, ModelPath, [], [], solver_mode);
else
    ImageQuality0 = importdata(MatFile);
    [~, ImageQuality{:}] = srdata.deployImgsByIterModels(ImgPairs, ModelPath, [], ImageQuality0{end}, solver_mode);
    if isempty(ImageQuality{end})
        ImageQuality = ImageQuality0;
        return
    end
    
    for k = 1 : size(ImageQuality, 2)
        ImageQuality{k} = [ImageQuality0{k} ImageQuality{k}];
    end
    [~, idx] = sort(ImageQuality{end});
    ImageQuality = cellfun(@(x)x(:, idx), ImageQuality, 'uniformoutput', false);
end

%%
save(MatFile, 'ImageQuality');
